#pragma once

#include <D3D11.h>
#include <D3DX11.h>
#include <DxErr.h>
#include <D3Dcompiler.h>
#include <d3dx11effect.h>
#include <dinput.h>

#include "../Common.h"
#include "CameraDevice.h"
#include "../Game/BoardMesh.h"
#include "../AssetManager.h"


namespace DirectX
{
  class CurrentContext
  {
  public:
    static CurrentContext& GetInstance();
    bool Init(HINSTANCE hInstance, HWND window);
    bool CompileShader(char* filePath, char *entry, char* shaderModel, ID3DBlob** buffer);
    bool CreateEffect(ID3DBlob* buffer, UINT flags, ID3DX11Effect** outEffect);
    

    ID3D11Device* Device;
    ID3D11DeviceContext* DeviceContext;
    D3D_DRIVER_TYPE DriverType;
    D3D_FEATURE_LEVEL FeatureLevel;

    IDXGISwapChain* SwapChain;
    ID3D11RenderTargetView* BackBufferTarget;

    ID3D11DepthStencilState* DepthStencilState;
    ID3D11DepthStencilView* DepthStencilView;
    ID3D11Texture2D* DepthTexture;

    ID3DX11Effect* Effect;
    ID3D11InputLayout* InputLayout;
    ID3D11InputLayout* InputLayoutRay;

    LPDIRECTINPUT8 DirectInput;

    LPDIRECTINPUTDEVICE8 KeyboardDevice;
    LPDIRECTINPUTDEVICE8 MouseDevice;

    char KeyboardKeys[256];
    char PrevKeyboardKeys[256];

    DIMOUSESTATE MouseState;
    DIMOUSESTATE PrevMouseState;

    long MousePosX;
    long MousePosY;
    long MouseWheel;

    int Width, Height;

    CameraDevice* Camera;
    Game::BoardMesh* Chessboard;
  private:
    CurrentContext();  
    
  };
}